<html>
<head><meta charset="utf-8"><title>datafrog-blog-post-feedback · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html">datafrog-blog-post-feedback</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="126791673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791673">(May 19 2018 at 10:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116609">@Frank McSherry</span> total nit, but I wonder if <code>impl Trait</code> would make this more readable:</p>
<p>before:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">join_helper</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">input1</span>: <span class="kp">&amp;</span><span class="nc">Relation</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="n">Val1</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">input2</span>: <span class="kp">&amp;</span><span class="nc">Relation</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">mut</span><span class="w"> </span><span class="n">result</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="c1">// do some stuff probably.</span>

<span class="p">}</span><span class="w"></span>
</pre></div>


<p>after (I'm also using the "rustfmt" style here):</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">join_helper</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">input1</span>: <span class="kp">&amp;</span><span class="nc">Relation</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="n">Val1</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">input2</span>: <span class="kp">&amp;</span><span class="nc">Relation</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">mut</span><span class="w"> </span><span class="n">result</span>: <span class="nc">impl</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">),</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="c1">// do some stuff probably.</span>

<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="126791716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791716">(May 19 2018 at 10:37)</a>:</h4>
<p>Interesting! I hadn't got around to testing <code>impl Trait</code> yet, but that does seem more tasteful.</p>



<a name="126791720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791720">(May 19 2018 at 10:37)</a>:</h4>
<p>so far it all reads very nicely to me — but then i'm definitely knee deep in this space right now :)</p>



<a name="126791761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791761">(May 19 2018 at 10:38)</a>:</h4>
<p>I find <code>impl Trait</code> in argument position is basically made for closures ;)</p>



<a name="126791762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791762">(May 19 2018 at 10:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116609">@Frank McSherry</span> in this line, you use <code>Fn</code> not <code>FnMut</code>, is there a reason for that (I don't immediately see why):</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">join_into</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="nb">Result</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">)</span>-&gt;<span class="nb">Result</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
</pre></div>



<a name="126791769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791769">(May 19 2018 at 10:39)</a>:</h4>
<p>though I guess most of the helpers wouldn't mutate environmental state anyway</p>



<a name="126791773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791773">(May 19 2018 at 10:39)</a>:</h4>
<p>Actually,  while I have you, why must I write this:</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">join_into</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="nb">Result</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">)</span>-&gt;<span class="nb">Result</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">input1</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">input2</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">output</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">logic</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">batch2</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">batch2</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="o">|</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">)));</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">batch1</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">batch1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="o">|</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">)));</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="o">|</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">)));</span><span class="w"></span>

<span class="w">    </span><span class="n">output</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">Relation</span>::<span class="n">from_vec</span><span class="p">(</span><span class="n">results</span><span class="p">));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>and not this</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">join_into</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="nb">Result</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">)</span>-&gt;<span class="nb">Result</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">input1</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">input2</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">output</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">logic</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="o">|</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">));</span><span class="w"></span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">batch2</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">batch2</span><span class="p">,</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">batch1</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">batch1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="n">output</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">Relation</span>::<span class="n">from_vec</span><span class="p">(</span><span class="n">results</span><span class="p">));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="126791818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791818">(May 19 2018 at 10:40)</a>:</h4>
<p>actually I'm not sure that you must :)</p>



<a name="126791819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791819">(May 19 2018 at 10:40)</a>:</h4>
<p>I get a bunch of errors (can link) that seem to be about the lifetimes in the <code>for &lt;'r, 's, 't&gt;</code> HRLs.</p>



<a name="126791820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791820">(May 19 2018 at 10:40)</a>:</h4>
<p>oh</p>



<a name="126791824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791824">(May 19 2018 at 10:41)</a>:</h4>
<div class="codehilite"><pre><span></span>Echidnatron% cargo test
   Compiling datafrog v0.1.0 (file:///Users/mcsherry/Projects/datafrog)
error[E0631]: type mismatch in closure arguments
  --&gt; src/join.rs:19:9
   |
16 |     let mut closure = |k,v1,v2| results.push(logic(k,v1,v2));
   |                       -------------------------------------- found signature of `fn(&amp;Key, &amp;Val1, &amp;Val2) -&gt; _`
...
19 |         join_helper(&amp;recent1, &amp;batch2, closure);
   |         ^^^^^^^^^^^ expected signature of `for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r Key, &amp;&#39;s Val1, &amp;&#39;t0 Val2) -&gt; _`
   |
note: required by `join::join_helper`
  --&gt; src/join.rs:51:1
   |
51 | fn join_helper&lt;K: Ord, V1, V2, F: FnMut(&amp;K,&amp;V1,&amp;V2)&gt;(mut slice1: &amp;[(K,V1)], mut slice2: &amp;[(K,V2)], mut result: F) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0271]: type mismatch resolving `for&lt;&#39;r, &#39;s, &#39;t0&gt; &lt;[closure@src/join.rs:16:23: 16:61 results:_, logic:_] as std::ops::FnOnce&lt;(&amp;&#39;r Key, &amp;&#39;s Val1, &amp;&#39;t0 Val2)&gt;&gt;::Output == ()`
  --&gt; src/join.rs:19:9
   |
19 |         join_helper(&amp;recent1, &amp;batch2, closure);
   |         ^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
   |
note: required by `join::join_helper`
  --&gt; src/join.rs:51:1
   |
51 | fn join_helper&lt;K: Ord, V1, V2, F: FnMut(&amp;K,&amp;V1,&amp;V2)&gt;(mut slice1: &amp;[(K,V1)], mut slice2: &amp;[(K,V2)], mut result: F) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
</pre></div>



<a name="126791827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791827">(May 19 2018 at 10:41)</a>:</h4>
<p>yeah you would need type annotations on the parameters</p>



<a name="126791829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791829">(May 19 2018 at 10:41)</a>:</h4>
<p>the reason is that, to infer which parameters have HRL, we use the "expected type"</p>



<a name="126791830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791830">(May 19 2018 at 10:41)</a>:</h4>
<p>that is, we look at the fn you are calling and the declared type on its parameter</p>



<a name="126791831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791831">(May 19 2018 at 10:41)</a>:</h4>
<p>if there is no expected type (as in the new code), then we will only infer a higher-ranked lifetime if it is manually given to us</p>



<a name="126791832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791832">(May 19 2018 at 10:42)</a>:</h4>
<p>I hope to improve this actually</p>



<a name="126791872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791872">(May 19 2018 at 10:42)</a>:</h4>
<p>but inferring higher-ranked things is a mite tricky so it may not work out</p>



<a name="126791873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791873">(May 19 2018 at 10:42)</a>:</h4>
<p>Re the <code>Fn</code> vs <code>FnMut</code>, no reason that I can think of. I think morally I imagined it would be a functional transformation of the inputs, but I can't see why <code>FnMut</code> shouldn't be permitted. Lemme fix that up too.</p>



<a name="126791874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791874">(May 19 2018 at 10:42)</a>:</h4>
<p>(I think that, if I could go back in time, I would require that closure's parameters have a type given if there is no expected type, but ...)</p>



<a name="126791881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791881">(May 19 2018 at 10:43)</a>:</h4>
<p>so iow something like this would probably work:</p>



<a name="126791885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791885">(May 19 2018 at 10:43)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="n">k</span>: <span class="kp">&amp;</span><span class="nc">Key</span><span class="p">,</span><span class="w"> </span><span class="n">v1</span>: <span class="kp">&amp;</span><span class="nc">Val1</span><span class="p">,</span><span class="w"> </span><span class="n">v2</span>: <span class="kp">&amp;</span><span class="nc">Val2</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">));</span><span class="w"></span>
</pre></div>



<a name="126791887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791887">(May 19 2018 at 10:43)</a>:</h4>
<p>or whatever the right types are</p>



<a name="126791933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791933">(May 19 2018 at 10:45)</a>:</h4>
<p>okies, that seems likely to work. getting errors now about the fact that the closure has a <code>&amp;mut</code> in it, so can't be cloned; will have to take closure by reference rather than owned, I think but should be ok.</p>



<a name="126791936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791936">(May 19 2018 at 10:45)</a>:</h4>
<p>Does <code>logic: &amp;mut impl Fn(&amp;blah)</code> work as well? (( also trying it out, but .. ))</p>



<a name="126791937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791937">(May 19 2018 at 10:46)</a>:</h4>
<p>yes that would work</p>



<a name="126791976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791976">(May 19 2018 at 10:46)</a>:</h4>
<p>however</p>



<a name="126791978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791978">(May 19 2018 at 10:46)</a>:</h4>
<p>you should not have to modify the callee I don't thnk</p>



<a name="126791979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791979">(May 19 2018 at 10:46)</a>:</h4>
<p>because <code>FnMut</code> is implemented for <code>&amp;mut F</code> where <code> F: FnMut</code></p>



<a name="126791980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791980">(May 19 2018 at 10:46)</a>:</h4>
<p>(iirc)</p>



<a name="126791982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791982">(May 19 2018 at 10:46)</a>:</h4>
<p>so you should be able to get by with just <code>logic: impl FnMut(..)</code></p>



<a name="126791983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791983">(May 19 2018 at 10:46)</a>:</h4>
<p>and then on the caller side doing <code>..., &amp;mut closure)</code></p>



<a name="126791989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126791989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126791989">(May 19 2018 at 10:47)</a>:</h4>
<p>though sometimes I forget just which adapters we actually have and I could be wrong :)</p>



<a name="126792038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792038">(May 19 2018 at 10:49)</a>:</h4>
<p>Cool, this seems to work:</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">join_into</span><span class="o">&lt;</span><span class="n">Key</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span>: <span class="nb">Ord</span><span class="p">,</span><span class="w"> </span><span class="nb">Result</span>: <span class="nb">Ord</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">input1</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val1</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">input2</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="p">(</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="n">Val2</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">output</span>: <span class="kp">&amp;</span><span class="nc">Variable</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">logic</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="nb">FnMut</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Key</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">Val2</span><span class="p">)</span>-&gt;<span class="nb">Result</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">recent2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">recent</span><span class="p">.</span><span class="n">borrow</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="n">k</span>: <span class="kp">&amp;</span><span class="nc">Key</span><span class="p">,</span><span class="w"> </span><span class="n">v1</span>: <span class="kp">&amp;</span><span class="nc">Val1</span><span class="p">,</span><span class="w"> </span><span class="n">v2</span>: <span class="kp">&amp;</span><span class="nc">Val2</span><span class="o">|</span><span class="w"> </span><span class="n">results</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">logic</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v1</span><span class="p">,</span><span class="n">v2</span><span class="p">));</span><span class="w"></span>

<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="n">batch2</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input2</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">batch2</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="n">batch1</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">input1</span><span class="p">.</span><span class="n">stable</span><span class="p">.</span><span class="n">borrow</span><span class="p">().</span><span class="n">iter</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">batch1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">        </span><span class="n">join_helper</span><span class="p">(</span><span class="o">&amp;</span><span class="n">recent1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">recent2</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">closure</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="n">output</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">Relation</span>::<span class="n">from_vec</span><span class="p">(</span><span class="n">results</span><span class="p">));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="126792083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792083">(May 19 2018 at 10:50)</a>:</h4>
<p>Scope needed to allow <code>closure</code> to drop and release borrow on <code>results</code>, so that it can be moved into <code>insert</code>.</p>



<a name="126792084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792084">(May 19 2018 at 10:50)</a>:</h4>
<blockquote>
<p>Well enough that I'm still blocked on them confirming that we've actually computed the same thing, before getting too sassy.</p>
</blockquote>
<p><span class="emoji emoji-1f923" title="rolling on the floor laughing">:rolling_on_the_floor_laughing:</span></p>



<a name="126792085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792085">(May 19 2018 at 10:50)</a>:</h4>
<p>Yeah, well you can't see how long it takes them. Want to guess the speed-up?</p>



<a name="126792091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792091">(May 19 2018 at 10:51)</a>:</h4>
<p>This is ASPLOS, one of the top architecture/systems conferences, right?</p>



<a name="126792092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792092">(May 19 2018 at 10:51)</a>:</h4>
<p>confirm</p>



<a name="126792130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792130">(May 19 2018 at 10:52)</a>:</h4>
<p>It's about a 200x speed-up.  And it's totally the right answer. Same number of tuples as them, but they rounded to millions so hard to be 100% certain.</p>



<a name="126792133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792133">(May 19 2018 at 10:52)</a>:</h4>
<p>introducing <span class="emoji emoji-1f438" title="frog">:frog:</span> COST</p>



<a name="126792134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792134">(May 19 2018 at 10:52)</a>:</h4>
<p>wow, I was going to guess 10x — then realized that must be too conservative</p>



<a name="126792135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792135">(May 19 2018 at 10:52)</a>:</h4>
<p>so I was going to up to 100x :)</p>



<a name="126792136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792136">(May 19 2018 at 10:52)</a>:</h4>
<p>they take 11mins to do it; 3 seconds of compute with <span class="emoji emoji-1f438" title="frog">:frog:</span>.</p>



<a name="126792144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792144">(May 19 2018 at 10:53)</a>:</h4>
<p>reading <span class="emoji emoji-1f438" title="frog">:frog:</span>'s implementation reminded me of some excellent lectures I was watching by Alex Stepanov</p>



<a name="126792145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792145">(May 19 2018 at 10:53)</a>:</h4>
<p>That's doing null pointer reachability on httpd. If you do it on postgres, it takes them 143.8 minutes. Guess for <span class="emoji emoji-1f438" title="frog">:frog:</span>.</p>



<a name="126792146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792146">(May 19 2018 at 10:53)</a>:</h4>
<p>he often claimed "computers are array processing machines", and — paraphrased — using any other data structure is folly</p>



<a name="126792148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792148">(May 19 2018 at 10:53)</a>:</h4>
<p>uh..10s :)</p>



<a name="126792187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792187">(May 19 2018 at 10:54)</a>:</h4>
<p>/me just picks a number out of the air</p>



<a name="126792188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792188">(May 19 2018 at 10:54)</a>:</h4>
<p>5s to load the data, then 9s to complete the compute.</p>



<a name="126792191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792191">(May 19 2018 at 10:54)</a>:</h4>
<p>wow</p>



<a name="126792195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792195">(May 19 2018 at 10:54)</a>:</h4>
<p>amazing</p>



<a name="126792196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792196">(May 19 2018 at 10:54)</a>:</h4>
<p>Current "bee in bonnet" is "people who have to invent systems because the existing systems are so bad".</p>



<a name="126792203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792203">(May 19 2018 at 10:55)</a>:</h4>
<p>Arguably the ASPLOS authors are sympathetic characters here. They took a Stanford system, and instead of 3s, or even 11 minutes, it takes them (Stanford) four hours to do the httpd null pointer analysis. =/</p>



<a name="126792243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792243">(May 19 2018 at 10:56)</a>:</h4>
<p>I am definitely feeling a desire to read those papers now</p>



<a name="126792246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792246">(May 19 2018 at 10:56)</a>:</h4>
<p>So they (the ASPLOS authors) are in a bit of a bind, in that the "big data" systems are just not suitable for what they are trying to do. And so they learn a bit about how to do this, but are just learning as they go.</p>



<a name="126792252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792252">(May 19 2018 at 10:57)</a>:</h4>
<p>PS your link for "real paper" leads to <a href="https://github.com/frankmcsherry/blog/blob/master/posts" target="_blank" title="https://github.com/frankmcsherry/blog/blob/master/posts">https://github.com/frankmcsherry/blog/blob/master/posts</a></p>



<a name="126792255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792255">(May 19 2018 at 10:57)</a>:</h4>
<p>which is maybe not what you meant</p>



<a name="126792256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792256">(May 19 2018 at 10:57)</a>:</h4>
<p>are they distributing the computation over a big cluster or something?</p>



<a name="126792257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792257">(May 19 2018 at 10:57)</a>:</h4>
<p>i.e., is part of the problem that they are paying a lot of synchronization overhead, but the quantity of data doesn't justify that?</p>



<a name="126792296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792296">(May 19 2018 at 10:58)</a>:</h4>
<p>Oh, right a few broken links at the moment sorry. (typed while out and about w/o internet).</p>



<a name="126792297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792297">(May 19 2018 at 10:58)</a>:</h4>
<p>no worries</p>



<a name="126792298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792298">(May 19 2018 at 10:58)</a>:</h4>
<p>just thought I'd mention it</p>



<a name="126792300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792300">(May 19 2018 at 10:58)</a>:</h4>
<p>No, this is single machine stuff they are doing. <a href="https://www.ics.uci.edu/~guoqingx/papers/wang-asplos17.pdf" target="_blank" title="https://www.ics.uci.edu/~guoqingx/papers/wang-asplos17.pdf">https://www.ics.uci.edu/~guoqingx/papers/wang-asplos17.pdf</a></p>



<a name="126792358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126792358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frank McSherry <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126792358">(May 19 2018 at 11:00)</a>:</h4>
<p>That <code>impl Fn</code> stuff is great. Much cleaner, even if just syntax. :)</p>



<a name="126793638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126793638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126793638">(May 19 2018 at 11:53)</a>:</h4>
<blockquote>
<p>We are going to reproduce their results!</p>
</blockquote>
<p>Readers will be able to predict how this will end</p>



<a name="126793683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback/near/126793683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/datafrog-blog-post-feedback.html#126793683">(May 19 2018 at 11:54)</a>:</h4>
<p>very nice post</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>